package com.tank.demo.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

@Data
@NoArgsConstructor
//@AllArgsConstructor
@ToString
public class ResourceMgr {
    public static BufferedImage myTankU,myTankL,myTankR,myTankD;
    public static BufferedImage enemyTankU,enemyTankL,enemyTankR,enemyTankD;
    public static BufferedImage bulletU,bulletL,bulletR,bulletD;
    public static BufferedImage[] blast = new BufferedImage[16];
    public static BufferedImage wall;
    static {
        try {
            myTankL = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/p1tankL.gif"));
            myTankU = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/p1tankU.gif"));
            myTankR = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/p1tankR.gif"));
            myTankD = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/p1tankD.gif"));

            enemyTankL = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/enemy1L.gif"));
            enemyTankU = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/enemy1U.gif"));
            enemyTankR = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/enemy1R.gif"));
            enemyTankD = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/enemy1D.gif"));

            bulletU = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/bullet.png"));
            bulletL = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/bulletL.png"));
            bulletR = ImageUtils.rotateImage(bulletL,180);
            bulletD = ImageUtils.rotateImage(bulletU,180);


            blast[0] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast1.gif"));
            blast[1] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast2.gif"));
            blast[2] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast3.gif"));
            blast[3] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast4.gif"));
            blast[4] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast5.gif"));
            blast[5] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast6.gif"));
            blast[6] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast7.gif"));
            blast[7] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast8.gif"));
            blast[8] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast7.gif"));
            blast[9] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast6.gif"));
            blast[10] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast5.gif"));
            blast[11] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast4.gif"));
            blast[12] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast3.gif"));
            blast[13] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast2.gif"));
            blast[14] = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/blast1.gif"));

            wall = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("static/img/wall/tugai.net.20101117145147.gif"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
